/**
 * @Title: model.js
 * @Description: model
 * @author: Fanchao
 * @date: 2020/9/28 8:39 下午
 * @version V1.0
 */

const { pathToRegexp } = require('path-to-regexp');

export default {
    namespace: 'dashboard',
    state: {
        weather: {
            city: '深圳',
            temperature: '30',
            name: '晴',
            icon: '//cdn.antd-admin.zuiidea.com/sun.png',
        },
        sales: [{
            'name': 2008,
            'Clothes': 407,
            'Food': 391,
            'Electronics': 396,
        }, {
            'name': 2009,
            'Clothes': 409,
            'Food': 342,
            'Electronics': 527,
        }, {
            'name': 2010,
            'Clothes': 449,
            'Food': 237,
            'Electronics': 370,
        }, {
            'name': 2011,
            'Clothes': 297,
            'Food': 398,
            'Electronics': 412,
        }, {
            'name': 2012,
            'Clothes': 418,
            'Food': 323,
            'Electronics': 315,
        }, {
            'name': 2013,
            'Clothes': 485,
            'Food': 248,
            'Electronics': 304,
        }, {
            'name': 2014,
            'Clothes': 276,
            'Food': 393,
            'Electronics': 391,
        }, {
            'name': 2015,
            'Clothes': 205,
            'Food': 246,
            'Electronics': 467,
        }],
        quote: {
            'name': 'Joho Doe',
            'title': 'Graphic Designer',
            'content': 'I\'m selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can\'t handle me at my worst, then you sure as hell don\'t deserve me at my best.',
            'avatar': '//cdn.antd-admin.zuiidea.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
        },
        numbers: [{
            'icon': 'pay-circle-o',
            'color': '#64ea91',
            'title': 'Online Review',
            'number': 2781,
        }, {
            'icon': 'team',
            'color': '#8fc9fb',
            'title': 'New Customers',
            'number': 3241,
        }, {
            'icon': 'message',
            'color': '#d897eb',
            'title': 'Active Projects',
            'number': 253,
        }, {
            'icon': 'shopping-cart',
            'color': '#f69899',
            'title': 'Referrals',
            'number': 4324,
        }],
        recentSales: [{
            'id': 1,
            'name': 'Williams',
            'status': 2,
            'price': 168.6,
            'date': '2015-09-08 05:12:36',
        }, {
            'id': 2,
            'name': 'Allen',
            'status': 1,
            'price': 47.41,
            'date': '2016-06-08 14:44:04',
        }, {
            'id': 3,
            'name': 'Martin',
            'status': 2,
            'price': 134.46,
            'date': '2015-02-16 15:22:11',
        }, {
            'id': 4,
            'name': 'Martinez',
            'status': 4,
            'price': 183.17,
            'date': '2016-08-10 11:43:26',
        }, {
            'id': 5,
            'name': 'Young',
            'status': 4,
            'price': 47.4,
            'date': '2015-04-27 21:37:31',
        }, {
            'id': 6,
            'name': 'Allen',
            'status': 2,
            'price': 125.9,
            'date': '2015-10-25 05:07:59',
        }, {
            'id': 7,
            'name': 'Anderson',
            'status': 3,
            'price': 46.75,
            'date': '2016-08-27 18:53:50',
        }, {
            'id': 8,
            'name': 'Davis',
            'status': 1,
            'price': 86.74,
            'date': '2016-07-10 10:55:36',
        }, {
            'id': 9,
            'name': 'Young',
            'status': 4,
            'price': 22.2,
            'date': '2015-12-12 14:25:11',
        }, {
            'id': 10,
            'name': 'Davis',
            'status': 2,
            'price': 181.9,
            'date': '2016-10-15 22:22:11',
        }, {
            'id': 11,
            'name': 'White',
            'status': 3,
            'price': 46.84,
            'date': '2015-10-05 17:51:49',
        }, {
            'id': 12,
            'name': 'Hall',
            'status': 3,
            'price': 43.57,
            'date': '2016-04-14 15:35:59',
        }, {
            'id': 13,
            'name': 'Hall',
            'status': 3,
            'price': 101.85,
            'date': '2016-02-21 02:32:40',
        }, {
            'id': 14,
            'name': 'Brown',
            'status': 2,
            'price': 20.86,
            'date': '2016-03-11 07:32:43',
        }, {
            'id': 15,
            'name': 'Wilson',
            'status': 3,
            'price': 123.87,
            'date': '2016-06-15 04:03:52',
        }, {
            'id': 16,
            'name': 'Anderson',
            'status': 3,
            'price': 31.43,
            'date': '2015-11-06 18:26:46',
        }, {
            'id': 17,
            'name': 'Brown',
            'status': 2,
            'price': 64.6,
            'date': '2016-04-27 22:30:57',
        }, {
            'id': 18,
            'name': 'Martin',
            'status': 2,
            'price': 106.63,
            'date': '2016-09-22 15:28:44',
        }, {
            'id': 19,
            'name': 'Jones',
            'status': 3,
            'price': 162.2,
            'date': '2015-08-29 08:28:14',
        }, {
            'id': 20,
            'name': 'Clark',
            'status': 3,
            'price': 193.31,
            'date': '2016-10-06 18:01:03',
        }, {
            'id': 21,
            'name': 'White',
            'status': 3,
            'price': 24.13,
            'date': '2015-03-24 01:50:51',
        }, {
            'id': 22,
            'name': 'Garcia',
            'status': 2,
            'price': 103.7,
            'date': '2016-05-09 16:19:19',
        }, {
            'id': 23,
            'name': 'Anderson',
            'status': 1,
            'price': 163.86,
            'date': '2016-12-12 09:23:07',
        }, {
            'id': 24,
            'name': 'Hernandez',
            'status': 2,
            'price': 82.72,
            'date': '2016-12-26 10:03:03',
        }, {
            'id': 25,
            'name': 'Brown',
            'status': 2,
            'price': 177.35,
            'date': '2016-05-03 17:44:42',
        }, {
            'id': 26,
            'name': 'Thomas',
            'status': 1,
            'price': 111.48,
            'date': '2015-04-11 06:46:40',
        }, {
            'id': 27,
            'name': 'Lewis',
            'status': 3,
            'price': 64.2,
            'date': '2015-03-19 14:17:14',
        }, {
            'id': 28,
            'name': 'Robinson',
            'status': 2,
            'price': 131.38,
            'date': '2015-12-29 07:16:25',
        }, {
            'id': 29,
            'name': 'Thompson',
            'status': 2,
            'price': 32.5,
            'date': '2015-08-03 09:32:26',
        }, {
            'id': 30,
            'name': 'Williams',
            'status': 3,
            'price': 122.36,
            'date': '2016-03-25 09:22:23',
        }, {
            'id': 31,
            'name': 'Martinez',
            'status': 1,
            'price': 184.2,
            'date': '2016-09-13 14:10:10',
        }, {
            'id': 32,
            'name': 'Walker',
            'status': 2,
            'price': 167.5,
            'date': '2016-06-22 03:54:14',
        }, {
            'id': 33,
            'name': 'White',
            'status': 2,
            'price': 17.16,
            'date': '2016-08-17 15:42:32',
        }, {
            'id': 34,
            'name': 'Brown',
            'status': 3,
            'price': 178.3,
            'date': '2016-11-27 12:10:37',
        }, {
            'id': 35,
            'name': 'Moore',
            'status': 2,
            'price': 107.24,
            'date': '2015-05-27 15:39:35',
        }, {
            'id': 36,
            'name': 'Gonzalez',
            'status': 1,
            'price': 35.56,
            'date': '2015-03-11 00:58:45',
        }],
        comments: [{
            'name': 'Anderson',
            'status': 3,
            'content': 'Bucvfumzcp qgbpqbs wrbs omlekv ictbjiqjj ovgvuejg tfujy eld sfootylo uognetmd jzbhl fcbwq ffzefh hverk mfsmlojyxd ztihce vodffkjc.',
            'avatar': 'http://dummyimage.com/48x48/7b79f2/757575.png&text=A',
            'date': '2016-10-17 20:36:44',
        }, {
            'name': 'Thompson',
            'status': 2,
            'content': 'Efybaneb gclanlit bxivjsxk jpq jhoouabkpr zmhidr pvvair rwn dwfrlrlw bcvwuskw vych zbpdgiuog hqfivqwpw fvlwift ijkrbi nkhu zejvyohkx droifze.',
            'avatar': 'http://dummyimage.com/48x48/99f279/757575.png&text=T',
            'date': '2016-02-26 22:59:28',
        }, {
            'name': 'Clark',
            'status': 3,
            'content': 'Nmnxkr qkei nicvpillc iuitrqzi ndip ihyximj tyuqudc vnmcr ewtxm ttnuqxxa iasis dcbilssl wjrxrud iqppsbcqi bbelkljq ibw mkuguis.',
            'avatar': 'http://dummyimage.com/48x48/f279bc/757575.png&text=C',
            'date': '2016-06-23 13:05:29',
        }, {
            'name': 'Hernandez',
            'status': 2,
            'content': 'Pirgenc opv gdbcexu qamgxlklw ppfy xwvymwxjp wwbhikepa ghxsrfamm jbrf plihgkygbn vmnevtxr hyhrfkye eqie vtno.',
            'avatar': 'http://dummyimage.com/48x48/79e0f2/757575.png&text=H',
            'date': '2016-12-03 05:14:07',
        }, {
            'name': 'Robinson',
            'status': 3,
            'content': 'Xamnv qstkagmh krm miwka gifhxr rjhohpvjox djlw dvftsovfd pfyblnwbjv ecjuiufbi mzhvadzio odqm ksek ntgxx caapxdxh lemiqiwkhk.',
            'avatar': 'http://dummyimage.com/48x48/f2e079/757575.png&text=R',
            'date': '2016-07-14 07:01:02',
        }],
        completed: [{
            'name': 2008,
            'Task complete': 328,
            'Cards Complete': 857,
        }, {
            'name': 2009,
            'Task complete': 794,
            'Cards Complete': 955,
        }, {
            'name': 2010,
            'Task complete': 950,
            'Cards Complete': 327,
        }, {
            'name': 2011,
            'Task complete': 417,
            'Cards Complete': 885,
        }, {
            'name': 2012,
            'Task complete': 711,
            'Cards Complete': 821,
        }, {
            'name': 2013,
            'Task complete': 764,
            'Cards Complete': 602,
        }, {
            'name': 2014,
            'Task complete': 375,
            'Cards Complete': 815,
        }, {
            'name': 2015,
            'Task complete': 793,
            'Cards Complete': 537,
        }, {
            'name': 2016,
            'Task complete': 585,
            'Cards Complete': 983,
        }, {
            'name': 2017,
            'Task complete': 413,
            'Cards Complete': 580,
        }, {
            'name': 2018,
            'Task complete': 349,
            'Cards Complete': 366,
        }, {
            'name': 2019,
            'Task complete': 987,
            'Cards Complete': 972,
        }],
        browser: [{
            'name': 'Google Chrome',
            'percent': 43.3,
            'status': 1,
        }, {
            'name': 'Mozilla Firefox',
            'percent': 33.4,
            'status': 2,
        }, {
            'name': 'Apple Safari',
            'percent': 34.6,
            'status': 3,
        }, {
            'name': 'Internet Explorer',
            'percent': 12.3,
            'status': 4,
        }, {
            'name': 'Opera Mini',
            'percent': 3.3,
            'status': 1,
        }, {
            'name': 'Chromium',
            'percent': 2.53,
            'status': 1,
        }],
        cpu: {
            'usage': 214,
            'space': 825,
            'cpu': 52,
            'data': [{
                'cpu': 54,
            }, {
                'cpu': 44,
            }, {
                'cpu': 23,
            }, {
                'cpu': 23,
            }, {
                'cpu': 48,
            }, {
                'cpu': 21,
            }, {
                'cpu': 59,
            }, {
                'cpu': 30,
            }, {
                'cpu': 66,
            }, {
                'cpu': 22,
            }, {
                'cpu': 41,
            }, {
                'cpu': 77,
            }, {
                'cpu': 55,
            }, {
                'cpu': 78,
            }, {
                'cpu': 46,
            }, {
                'cpu': 59,
            }, {
                'cpu': 41,
            }, {
                'cpu': 49,
            }, {
                'cpu': 40,
            }, {
                'cpu': 30,
            }],
        },
        user: {
            'name': 'github',
            'sales': 3241,
            'sold': 3556,
        },
    },
    subscriptions: {
        setup({ dispatch, history }) {
            history.listen(({ pathname }) => {
                if (
                    pathToRegexp('/dashboard').exec(pathname) ||
                    pathToRegexp('/').exec(pathname)
                ) {
                    // dispatch({ type: 'query' });
                    // dispatch({ type: 'queryWeather' });
                }
            });
        },
    },
    effects: {
        // * query({ payload }, { call, put }) {
        //     const data = yield call(queryDashboard, parse(payload));
        //     yield put({
        //         type: 'updateState',
        //         payload: data,
        //     });
        // },
        // * queryWeather({ payload = {} }, { call, put }) {
        //     payload.location = 'shenzhen';
        //     const result = yield call(queryWeather, payload);
        //     const { success } = result;
        //     if (success) {
        //         const data = result.results[0];
        //         const weather = {
        //             city: data.location.name,
        //             temperature: data.now.temperature,
        //             name: data.now.text,
        //             icon: `//cdn.antd-admin.zuiidea.com/web/icons/3d_50/${data.now.code}.png`,
        //         };
        //         yield put({
        //             type: 'updateState',
        //             payload: {
        //                 weather,
        //             },
        //         });
        //     }
        // },
    },
};
